2008

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 19
Psychology and social sciences 11
Education 7
Humanities and arts 5
Mathematics and computer sciences 3
Other 3
Engineering 1

Top 10

field Total
Social sciences 4278
Physics 1586
Educational leadership 1573
Computer science 1499
Clinical psychology 1142
Other economics 1055
Biochemistry (biological sciences) 899
Neurosciences, neurobiologye 883
Molecular biology 786
Curriculum and instruction 744

2009

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 19
Psychology and social sciences 11
Education 7
Humanities and arts 5
Mathematics and computer sciences 3
Other 3
Engineering 1

Top 10

field Total
Social sciences 4473
Physics 1630
Educational leadership 1561
Computer science 1361
Clinical psychology 1201
Other economics 1087
Neurosciences, neurobiologye 983
Biochemistry (biological sciences) 858
Curriculum and instruction 782
Molecular biology 763

2010

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 19
Psychology and social sciences 11
Education 5
Humanities and arts 5
Mathematics and computer sciences 3
Other 3
Engineering 1

Top 10

field Total
Social sciences 4462
Physics 1563
Computer science 1356
Clinical psychology 1151
Other economics 1039
Educational leadership 1029
Neurosciences, neurobiologye 954
Biochemistry (biological sciences) 861
Molecular biology 697
Curriculum and instruction 617

2011

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 20
Psychology and social sciences 12
Education 5
Humanities and arts 5
Mathematics and computer sciences 3
Other 3
Engineering 2

Top 10

field Total
Social sciences 4645
Physics 1700
Computer science 1393
Clinical psychology 1229
Other economics 1093
Neurosciences, neurobiologye 958
Biochemistry (biological sciences) 867
Molecular biology 716
Organic chemistry 663
Educational leadership 649

2012

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 20
Psychology and social sciences 12
Humanities and arts 6
Education 5
Mathematics and computer sciences 3
Other 3
Engineering 2

Top 10

field Total
Social sciences 4899
Physics 1788
Computer science 1482
Clinical psychology 1228
Other economics 1155
Neurosciences, neurobiologye 1053
Biochemistry (biological sciences) 847
Educational leadership 673
Organic chemistry 667
Molecular biology 620

2013

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 21
Psychology and social sciences 12
Humanities and arts 6
Education 5
Mathematics and computer sciences 4
Other 3
Engineering 2

Top 10

field Total
Social sciences 4988
Physics 1810
Computer science 1568
Clinical psychology 1140
Other economics 1086
Neurosciences, neurobiologye 1016
Biochemistry (biological sciences) 827
Molecular biology 646
Organic chemistry 643
Educational leadership 601

2014

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 22
Psychology and social sciences 12
Humanities and arts 6
Education 5
Mathematics and computer sciences 4
Other 3
Engineering 2

Top 10

field Total
Social sciences 5027
Physics 1850
Computer science 1664
Clinical psychology 1220
Other economics 1100
Neurosciences, neurobiologye 1048
Biochemistry (biological sciences) 820
Molecular biology 670
Educational leadership 605
Organic chemistry 605

2015

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 22
Psychology and social sciences 13
Humanities and arts 6
Education 5
Mathematics and computer sciences 4
Other 3
Engineering 2

Top 10

field Total
Social sciences 5302
Physics 1924
Computer science 1658
Clinical psychology 1172
Other economics 1168
Neurosciences, neurobiologye 1091
Biochemistry (biological sciences) 749
Molecular biology 632
Organic chemistry 626
Educational leadership 620

2016

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 22
Psychology and social sciences 13
Education 5
Humanities and arts 5
Mathematics and computer sciences 4
Other 3
Engineering 2

Top 10

field Total
Social sciences 5129
Physics 2006
Computer science 1651
Clinical psychology 1217
Other economics 1139
Neurosciences, neurobiologye 997
Biochemistry (biological sciences) 832
Biological and biomedical sciences, general 770
Mathematics and statistics, general 686
Geological sciences 618

2017

Row

Phd Tree

PhDs by Broad Field (Thousands)

Broad field Total
Life sciences 22
Psychology and social sciences 13
Education 5
Humanities and arts 5
Mathematics and computer sciences 4
Other 3
Engineering 2

Top 10

field Total
Social sciences 5119
Physics 1883
Computer science 1587
Other economics 1161
Clinical psychology 1149
Neurosciences, neurobiologye 985
Biochemistry (biological sciences) 815
Molecular biology 624
Educational leadership 591
Geological sciences 576
---
title: "Dashboard for Week 9 2019 #TidyTuesday"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: fill
    theme: bootstrap
    source_code: embed
---
  
```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(readr)
library(tidyr)
library(collapsibleTree)
library(formattable)
```

```{r data, include = FALSE}
phd_field <- read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-02-19/phd_by_field.csv")

create_collapsible_tree <- function(phd_field,yr) {
  phd_field %>%
    filter(
      year == yr,
      !is.na(n_phds)
    ) %>%
    collapsibleTreeSummary(
      hierarchy = c("broad_field", "major_field", "field"),
      attribute = "n_phds",
      zoomable = F
    )
}

phds_by_broad <- function(phd_field, yr) {
  phd_field %>%
    filter(year == yr) %>%
    replace_na(list(n_phds = 0)) %>%
    group_by(broad_field) %>%
    summarise(Total = round(sum(n_phds) / 1000)) %>%
    rename(`Broad field` = broad_field) %>%
    arrange(desc(Total)) %>% 
    formattable(list(
      Total = color_tile("white", "orange")
    ))
}

top_fields <- function(phd_field, yr) {
  phd_field %>%
    filter(year == yr) %>%
    replace_na(list(n_phds = 0)) %>%
    group_by(field) %>%
    summarise(Total = sum(n_phds)) %>%
    top_n(10) %>%
    arrange(desc(Total)) %>% 
    formattable(list(
      Total = color_tile("white", "#56B4E9")
    ))
}
```

2008
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2008)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2008)
```

### Top 10

```{r}
top_fields(phd_field, 2008)
```

2009
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2009)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2009)
```

### Top 10

```{r}
top_fields(phd_field, 2009)
```

2010
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2010)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2010)
```

### Top 10

```{r}
top_fields(phd_field, 2010)
```

2011
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2011)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2011)
```

### Top 10

```{r}
top_fields(phd_field, 2011)
```

2012
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2012)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2012)
```

### Top 10

```{r}
top_fields(phd_field, 2012)
```

2013
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2013)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2013)
```

### Top 10

```{r}
top_fields(phd_field, 2013)
```

2014
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2014)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2014)
```

### Top 10

```{r}
top_fields(phd_field, 2014)
```

2015
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2015)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2015)
```

### Top 10

```{r}
top_fields(phd_field, 2015)
```

2016
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2016)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2016)
```

### Top 10

```{r}
top_fields(phd_field, 2016)
```

2017
=======================================================================

Row {.tabset .tabset-fade}
-----------------------------------------------------------------------

### Phd Tree

```{r}
create_collapsible_tree(phd_field, 2017)
```

### PhDs by Broad Field (Thousands)

```{r}
phds_by_broad(phd_field, 2017)
```

### Top 10

```{r}
top_fields(phd_field, 2017)
```